package com.shangsi;

import com.alibaba.cloud.nacos.ribbon.NacosRule;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.netflix.loadbalancer.ZoneAvoidanceRule;
import com.shangsi.config.FeignClientConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

import java.util.Random;

/**
 * @author dzd
 * @date 2021-12-16
 */
@SpringBootApplication
@EnableDiscoveryClient
//可以在这里指定 也可以直接加到容器
//@EnableFeignClients(defaultConfiguration = FeignClientConfiguration.class)
@EnableFeignClients
public class ConsumerNacosOrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConsumerNacosOrderApplication.class,args);
    }


    /**
     * 自定义负载均衡原则
     * @return IRule
     */
    @Bean
    public IRule getRule(){
        return new NacosRule();
       // return new  RandomRule();
    }
}
